home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / effects / effectClasses / MoveInstance.as < prev    next >
Text File  |  2014-03-27  |  8KB  |  256 lines

  1. package mx.effects.effectClasses
  2. {
  3.    import flash.events.Event;
  4.    import mx.core.Container;
  5.    import mx.core.EdgeMetrics;
  6.    import mx.core.IUIComponent;
  7.    import mx.core.mx_internal;
  8.    import mx.effects.EffectManager;
  9.    import mx.events.MoveEvent;
  10.    import mx.styles.IStyleClient;
  11.    
  12.    use namespace mx_internal;
  13.    
  14.    public class MoveInstance extends TweenEffectInstance
  15.    {
  16.       
  17.       mx_internal static const VERSION:String = "3.0.0.0";
  18.        
  19.       
  20.       public var xFrom:Number;
  21.       
  22.       public var yFrom:Number;
  23.       
  24.       private var left;
  25.       
  26.       private var forceClipping:Boolean = false;
  27.       
  28.       public var xTo:Number;
  29.       
  30.       private var top;
  31.       
  32.       private var horizontalCenter;
  33.       
  34.       public var yTo:Number;
  35.       
  36.       private var oldWidth:Number;
  37.       
  38.       private var right;
  39.       
  40.       private var bottom;
  41.       
  42.       private var oldHeight:Number;
  43.       
  44.       public var xBy:Number;
  45.       
  46.       public var yBy:Number;
  47.       
  48.       private var checkClipping:Boolean = true;
  49.       
  50.       private var verticalCenter;
  51.       
  52.       public function MoveInstance(param1:Object)
  53.       {
  54.          super(param1);
  55.       }
  56.       
  57.       override public function initEffect(param1:Event) : void
  58.       {
  59.          super.initEffect(param1);
  60.          if(param1 is MoveEvent && param1.type == MoveEvent.MOVE)
  61.          {
  62.             if(isNaN(xFrom) && isNaN(xTo) && isNaN(xBy) && isNaN(yFrom) && isNaN(yTo) && isNaN(yBy))
  63.             {
  64.                xFrom = MoveEvent(param1).oldX;
  65.                xTo = target.x;
  66.                yFrom = MoveEvent(param1).oldY;
  67.                yTo = target.y;
  68.             }
  69.          }
  70.       }
  71.       
  72.       override public function play() : void
  73.       {
  74.          var _loc2_:EdgeMetrics = null;
  75.          var _loc3_:Number = NaN;
  76.          var _loc4_:Number = NaN;
  77.          var _loc5_:Number = NaN;
  78.          var _loc6_:Number = NaN;
  79.          var _loc7_:Number = NaN;
  80.          var _loc8_:Number = NaN;
  81.          super.play();
  82.          EffectManager.mx_internal::startBitmapEffect(IUIComponent(target));
  83.          if(isNaN(xFrom))
  84.          {
  85.             xFrom = !isNaN(xTo) && !isNaN(xBy) ? Number(xTo - xBy) : Number(target.x);
  86.          }
  87.          if(isNaN(xTo))
  88.          {
  89.             if(isNaN(xBy) && propertyChanges && propertyChanges.end["x"] !== undefined)
  90.             {
  91.                xTo = propertyChanges.end["x"];
  92.             }
  93.             else
  94.             {
  95.                xTo = !isNaN(xBy) ? Number(xFrom + xBy) : Number(target.x);
  96.             }
  97.          }
  98.          if(isNaN(yFrom))
  99.          {
  100.             yFrom = !isNaN(yTo) && !isNaN(yBy) ? Number(yTo - yBy) : Number(target.y);
  101.          }
  102.          if(isNaN(yTo))
  103.          {
  104.             if(isNaN(yBy) && propertyChanges && propertyChanges.end["y"] !== undefined)
  105.             {
  106.                yTo = propertyChanges.end["y"];
  107.             }
  108.             else
  109.             {
  110.                yTo = !isNaN(yBy) ? Number(yFrom + yBy) : Number(target.y);
  111.             }
  112.          }
  113.          tween = createTween(this,[xFrom,yFrom],[xTo,yTo],duration);
  114.          var _loc1_:Container = target.parent as Container;
  115.          if(_loc1_)
  116.          {
  117.             _loc2_ = _loc1_.viewMetrics;
  118.             _loc3_ = _loc2_.left;
  119.             _loc4_ = _loc1_.width - _loc2_.right;
  120.             _loc5_ = _loc2_.top;
  121.             _loc6_ = _loc1_.height - _loc2_.bottom;
  122.             if(xFrom < _loc3_ || xTo < _loc3_ || xFrom + target.width > _loc4_ || xTo + target.width > _loc4_ || yFrom < _loc5_ || yTo < _loc5_ || yFrom + target.height > _loc6_ || yTo + target.height > _loc6_)
  123.             {
  124.                forceClipping = true;
  125.                _loc1_.mx_internal::forceClipping = true;
  126.             }
  127.          }
  128.          mx_internal::applyTweenStartValues();
  129.          if(target is IStyleClient)
  130.          {
  131.             left = target.getStyle("left");
  132.             if(left != undefined)
  133.             {
  134.                target.setStyle("left",undefined);
  135.             }
  136.             right = target.getStyle("right");
  137.             if(right != undefined)
  138.             {
  139.                target.setStyle("right",undefined);
  140.             }
  141.             top = target.getStyle("top");
  142.             if(top != undefined)
  143.             {
  144.                target.setStyle("top",undefined);
  145.             }
  146.             bottom = target.getStyle("bottom");
  147.             if(bottom != undefined)
  148.             {
  149.                target.setStyle("bottom",undefined);
  150.             }
  151.             horizontalCenter = target.getStyle("horizontalCenter");
  152.             if(horizontalCenter != undefined)
  153.             {
  154.                target.setStyle("horizontalCenter",undefined);
  155.             }
  156.             verticalCenter = target.getStyle("verticalCenter");
  157.             if(verticalCenter != undefined)
  158.             {
  159.                target.setStyle("verticalCenter",undefined);
  160.             }
  161.             if(left != undefined && right != undefined)
  162.             {
  163.                _loc7_ = target.width;
  164.                oldWidth = target.explicitWidth;
  165.                target.width = _loc7_;
  166.             }
  167.             if(top != undefined && bottom != undefined)
  168.             {
  169.                _loc8_ = target.height;
  170.                oldHeight = target.explicitHeight;
  171.                target.height = _loc8_;
  172.             }
  173.          }
  174.       }
  175.       
  176.       override public function onTweenUpdate(param1:Object) : void
  177.       {
  178.          var _loc2_:Container = null;
  179.          var _loc3_:EdgeMetrics = null;
  180.          var _loc4_:Number = NaN;
  181.          var _loc5_:Number = NaN;
  182.          var _loc6_:Number = NaN;
  183.          var _loc7_:Number = NaN;
  184.          EffectManager.suspendEventHandling();
  185.          if(!forceClipping && checkClipping)
  186.          {
  187.             _loc2_ = target.parent as Container;
  188.             if(_loc2_)
  189.             {
  190.                _loc3_ = _loc2_.viewMetrics;
  191.                _loc4_ = _loc3_.left;
  192.                _loc5_ = _loc2_.width - _loc3_.right;
  193.                _loc6_ = _loc3_.top;
  194.                _loc7_ = _loc2_.height - _loc3_.bottom;
  195.                if(param1[0] < _loc4_ || param1[0] + target.width > _loc5_ || param1[1] < _loc6_ || param1[1] + target.height > _loc7_)
  196.                {
  197.                   forceClipping = true;
  198.                   _loc2_.mx_internal::forceClipping = true;
  199.                }
  200.             }
  201.          }
  202.          target.move(param1[0],param1[1]);
  203.          EffectManager.resumeEventHandling();
  204.       }
  205.       
  206.       override public function onTweenEnd(param1:Object) : void
  207.       {
  208.          var _loc2_:Container = null;
  209.          EffectManager.mx_internal::endBitmapEffect(IUIComponent(target));
  210.          if(left != undefined)
  211.          {
  212.             target.setStyle("left",left);
  213.          }
  214.          if(right != undefined)
  215.          {
  216.             target.setStyle("right",right);
  217.          }
  218.          if(top != undefined)
  219.          {
  220.             target.setStyle("top",top);
  221.          }
  222.          if(bottom != undefined)
  223.          {
  224.             target.setStyle("bottom",bottom);
  225.          }
  226.          if(horizontalCenter != undefined)
  227.          {
  228.             target.setStyle("horizontalCenter",horizontalCenter);
  229.          }
  230.          if(verticalCenter != undefined)
  231.          {
  232.             target.setStyle("verticalCenter",verticalCenter);
  233.          }
  234.          if(left != undefined && right != undefined)
  235.          {
  236.             target.explicitWidth = oldWidth;
  237.          }
  238.          if(top != undefined && bottom != undefined)
  239.          {
  240.             target.explicitHeight = oldHeight;
  241.          }
  242.          if(forceClipping)
  243.          {
  244.             _loc2_ = target.parent as Container;
  245.             if(_loc2_)
  246.             {
  247.                forceClipping = false;
  248.                _loc2_.mx_internal::forceClipping = false;
  249.             }
  250.          }
  251.          checkClipping = false;
  252.          super.onTweenEnd(param1);
  253.       }
  254.    }
  255. }
  256.